<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
import { useAuthStore } from '@/stores/auth';

// 获取 Pinia store 实例
const authStore = useAuthStore();

// 检查登录状态的函数
function checkLoginStatus() {
  if (!authStore.isLoggedIn) {
    uni.navigateTo({
      url: '/pages/login/login'  // 跳转到登录页面
    });
  }
}

// 应用启动时
onLaunch(() => {
  checkLoginStatus();
});

// 应用显示时
onShow(() => {
  checkLoginStatus();
});

// 应用隐藏时
onHide(() => {
  console.log('App Hide');
});
</script>

<style lang="scss">
// 字体图标
@import '@/styles/fonts.scss';

view,
navigator,
input,
scroll-view {
  box-sizing: border-box;
}

button::after {
  border: none;
}

swiper,
scroll-view {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

image {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

// 两行省略
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
</style>
